package jwdt.xadmin.system.action;

import jwdt.common.action.BaseAction;
import jwdt.common.util.CacheUtil;
import jwdt.xadmin.system.bean.FL;
import jwdt.xadmin.system.service.FlManageService;

import com.ezerg.db.Jdb;
import com.ezerg.db.ext.PageUtil;
import com.ezerg.web.Form;
import com.ezerg.web.Module;
import com.ezerg.web.Page;
import com.ezerg.web.annotation.Controller;
import com.ezerg.web.annotation.RequestMapping;

@Controller("/xadmin/system")
public class FlManageAction extends BaseAction {
	
	private FlManageService flManageService = (FlManageService)app.getBean("flManageService");
	
	@RequestMapping("/listFl")
	public Page doListFl(Form f, Module m) throws Exception {
		PageUtil pu = (PageUtil)f.copy2Class(PageUtil.class);
    	return m.getWritePage(f, flManageService.doList(pu).toJson());
	}
	
	@RequestMapping("/addFl")
	public Page doAddact(Form f, Module m) throws Exception {
		FL obj = (FL)f.copy2Class(FL.class);
		return m.getWritePage(f, flManageService.doAddact(obj));
	}
	
	@RequestMapping("/editFl")
	public Page doEditact(Form f, Module m) throws Exception {
		int flid = f.getInt("flid");
		FL obj = (FL)f.copy2Class(FL.class);
		return m.getWritePage(f, flManageService.doEditact(obj, flid));
	}
	
	@RequestMapping("/delFl")
	public Page doDel(Form f, Module m) throws Exception {
		int flid = f.getInt("flid");
		return m.getWritePage(f, flManageService.doDelact(flid));
	}
	
	@RequestMapping("/flWindow")
	public Page doLoad(Form f, Module m) throws Exception {
		int flid = f.getInt("flid");
		f.add("obj", flManageService.doLoad(flid));
		return m.findPage("/xadmin/system/flWindow");
	}
	
	@RequestMapping("/listFlForCombox")
	public Page doListFlForCombox(Form f, Module m) throws Exception {
		//生成json字符串
    	return m.getJsonPage(f, Jdb.get().query("select flid, flmc from jwdt_zd_fl ORDER BY flid asc", CacheUtil.C0));
	}
}
